package com.androidhive.androidlistview;


import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class AppEntrance extends ListActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        // storing string resources into Array
        String[] adobe_products = getResources().getStringArray(R.array.adobe_products);
        
        // Binding Array to ListAdapter
        this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products));
        
        ListView lv = getListView();

        // listening to single list item on click
        lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view,
              int position, long id) {
        	  
        	  // selected item 
        	  String product = ((TextView) view).getText().toString();
        	  if(product.equalsIgnoreCase("Vendor Login")){
        	  // Launching new Activity on selecting single List Item
        	  Intent i = new Intent(getApplicationContext(), MainActivity.class);
        	  // sending data to new activity
        	  i.putExtra("product", product+"rk");
        	  startActivity(i);
        	
          }
        	  if(product.equalsIgnoreCase("About Us")){
            	  // Launching new Activity on selecting single List Item
            	  Intent i = new Intent(getApplicationContext(), AboutUs.class);
            	  // sending data to new activity
            	  i.putExtra("product", product+"rk");
            	  startActivity(i);
            	
              }
        	  if(product.equalsIgnoreCase("Help")){
            	  // Launching new Activity on selecting single List Item
            	  Intent i = new Intent(getApplicationContext(), Help.class);
            	  // sending data to new activity
            	  i.putExtra("product", product+"rk");
            	  startActivity(i);
            	
              }
        	  if(product.equalsIgnoreCase("Contact Us")){
            	  // Launching new Activity on selecting single List Item
            	  Intent i = new Intent(getApplicationContext(), ContactUs.class);
            	  // sending data to new activity
            	  i.putExtra("product", product+"rk");
            	  startActivity(i);
            	
              }
        	  if(product.equalsIgnoreCase("Farmer Login")){
            	  // Launching new Activity on selecting single List Item
            	  Intent i = new Intent(getApplicationContext(), FLogin.class);
            	  // sending data to new activity
            	  i.putExtra("product", product+"rk");
            	  startActivity(i);
            	
              }}
        });
    }
}